<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected function _initRouter(){
//		$front = Zend_Controller_Front::getInstance();      
		$front = Zend_Controller_Front::getInstance(); 
		$front->addControllerDirectory(APPLICATION_PATH . "/controllers");
		$router = $front->getRouter();
		$router->removeDefaultRoutes();
		$router->addRoute(
				'userControllerAction',
				new Zend_Controller_Router_Route('/:username/:controller/:action/*',array('username'=>':username'))
				);		
		$router->addRoute(
				'userController',
				new Zend_Controller_Router_Route('/:username/:controller/',array('action'=>'index'))
				);
		$router->addRoute(
				'user',
				new Zend_Controller_Router_Route('/:username/',array('controller'=>'wall','action'=>'index'))
				);
		$router->addRoute(
				'noparam',
				new Zend_Controller_Router_Route('',array('controller'=>'index','action'=>'index'))
				);
//				Zend_Debug::dump($router);
	}
	protected function _initDb() {
//		echo 'tesr';die;
	
		$dbOption = $this->getOption('resources');
    	$dbOption = $dbOption['db'];
    	
        // Setup database
        $db = Zend_Db::factory($dbOption['adapter'],$dbOption['params']);
        $db->setFetchMode(Zend_Db::FETCH_ASSOC);
        $db->query("SET NAMES 'utf8'");
        $db->query("SET CHARACTER SET 'utf8'");       
       
        Zend_Registry::set('connectDB',$db);
                
        //Khi thiet lap che do nay model moi co the su dung duoc
        Zend_Db_Table::setDefaultAdapter($db);
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
        // Return it, so that it can be stored by the bootstrap
        return $db;
	}
	

}

